prolog './gsp530l.ijs'
NB. } index list ---------------------------------------------------------

d=: (?23 5$2)*?23 5 7 3 2$4

f=: 3 : '(0 i}d) -: 0 i}s=:(2;y)$.d'
c=: ; (i.1+r) <"1@comb&.>r=:#$d

] b=: f&>c [ i=: <?@(   12&$)&.>1{.$d
] b=: f&>c [ i=: <?@(  2 6&$)&.>2{.$d
] b=: f&>c [ i=: <?@(2 2 3&$)&.>3{.$d
] b=: f&>c [ i=: <?@(  4 3&$)&.>4{.$d
] b=: f&>c [ i=: <?@(1 3 3&$)&.>5{.$d

] b=: f&>c [ i=: <''
] b=: f&>c [ i=: <a:;?3$5
] b=: f&>c [ i=: <a:;a:;?4$7
] b=: f&>c [ i=: <a:;a:;a:;?2$3
] b=: f&>c [ i=: <a:;a:;a:;a:;?2

] b=: f&>c [ i=: <<i.0
] b=: f&>c [ i=: <a:;i.0
] b=: f&>c [ i=: <a:;a:;i.0
] b=: f&>c [ i=: <a:;a:;a:;i.0
] b=: f&>c [ i=: <a:;a:;a:;a:i.0

d=: (?23 5$2)*?23 5 7 3 2$4

f=: 4 : '(x i}d) -: x i}s=:(2;y)$.d'
c=: ; (i.1+r) <"1@comb&.>r=:#$d

] b=: 99 f&>c [ i=: <?@(   12&$)&.>1{.$d
] b=: 99 f&>c [ i=: <?@(  2 6&$)&.>2{.$d
] b=: 99 f&>c [ i=: <?@(2 2 3&$)&.>3{.$d
] b=: 99 f&>c [ i=: <?@(  4 3&$)&.>4{.$d
] b=: 99 f&>c [ i=: <?@(1 3 3&$)&.>5{.$d

] b=: 99 f&>c [ i=: <''
] b=: 99 f&>c [ i=: <a:;?3$5
] b=: 99 f&>c [ i=: <a:;a:;?4$7
] b=: 99 f&>c [ i=: <a:;a:;a:;?2$3
] b=: 99 f&>c [ i=: <a:;a:;a:;a:;?2

] b=: 99 f&>c [ i=: <<i.0
] b=: 99 f&>c [ i=: <a:;i.0
] b=: 99 f&>c [ i=: <a:;a:;i.0
] b=: 99 f&>c [ i=: <a:;a:;a:;i.0
] b=: 99 f&>c [ i=: <a:;a:;a:;a:i.0

d=: (?23 5$2)*?23 5 7 3 2$4

f=: 3 : '(a i}d) -: a i}s=:(2;y)$.d [ a=: ?($i{d)$100'
c=: ; (i.1+r) <"1@comb&.>r=:#$d

] b=: f&>c [ i=: <?@(   12&$)&.>1{.$d
] b=: f&>c [ i=: <?@(  2 6&$)&.>2{.$d
] b=: f&>c [ i=: <?@(2 2 3&$)&.>3{.$d
] b=: f&>c [ i=: <?@(  4 3&$)&.>4{.$d
] b=: f&>c [ i=: <?@(1 3 3&$)&.>5{.$d

] b=: f&>c [ i=: <''
] b=: f&>c [ i=: <a:;?3$5
] b=: f&>c [ i=: <a:;a:;?4$7
] b=: f&>c [ i=: <a:;a:;a:;?2$3
] b=: f&>c [ i=: <a:;a:;a:;a:;?2

] b=: f&>c [ i=: <<i.0
] b=: f&>c [ i=: <a:;i.0
] b=: f&>c [ i=: <a:;a:;i.0
] b=: f&>c [ i=: <a:;a:;a:;i.0
] b=: f&>c [ i=: <a:;a:;a:;a:i.0

d=: (?23 5$2)*?23 5 7 3 2$4
f=: 3 : '(100+d) -: (100+d) i}s=:(2;y)$.d'

f&>c [ i=: <''
f&>c [ i=: <$0


NB. amend in place -------------------------------------------------------

d=: (0=?7 5$3)*?7 5 1000$1000
s=: (2;0 1)$.d

i=: <"0 (?#i){i=: 4$.s
9000 > 7!:2 's=: 0     (<i,<1 3 5)}s'
s -: d=: 0     (<i,<1 3 5)}d
scheck s

i=: <"0 (?#i){i=: 4$.s
(IF64{9000 18000) > t=: 7!:2 's=: 7 8 9 (<i,<1 3 5)}s'
s -: d=: 7 8 9 (<i,<1 3 5)}d
scheck s

i=: <"0 (?#i){i=:(7 5#:i.35)-.4$.s
s=: 7 8 9 (<i,<1 3 5)}s  NB. not in place
s -: d=: 7 8 9 (<i,<1 3 5)}d
scheck s


NB. amend in place with sparse replacement data --------------------------

d=: (0=?7 5$3)*?7 5 1000$1000
s=: (2;0 1)$.d

i=: <"0 (?#i){i=: 4$.s
x=: $. 7 8 9
(IF64{9000 18000) > t=: 7!:2 's=: x (<i,<1 3 5)}s'
s -: d=: x (<i,<1 3 5)}d
scheck s

i=: <"0 (?#i){i=:(7 5#:i.35)-.4$.s
s=: x (<i,<1 3 5)}s  NB. not in place
s -: d=: x (<i,<1 3 5)}d
scheck s


NB. sparse replacement data ----------------------------------------------

d=: (?23 5$2) * ?23 5 3 2 4$5
c=: ; (i.1+r) <"1@comb&.>r=:#$d

f=: 3 : '(a i}d) -: ($.a) i}s=:(2;y)$.d [ a=: g i'
g=: 3 : '($y{d) ?@$ 7'

] b=: f&>c [ i=: < ?&.> 2 3&$&.>i{.$d [ i=: 1
] b=: f&>c [ i=: < ?&.> 2 3&$&.>i{.$d [ i=: 2
] b=: f&>c [ i=: < ?&.> 2 3&$&.>i{.$d [ i=: 3
] b=: f&>c [ i=: < ?&.> 2 3&$&.>i{.$d [ i=: 4
] b=: f&>c [ i=: < ?&.> 2 3&$&.>i{.$d [ i=: 5

] b=: f&>c [ i=: < ?&.> (>:?i$7)$&.>i{.$d [ i=: 1
] b=: f&>c [ i=: < ?&.> (>:?i$7)$&.>i{.$d [ i=: 2
] b=: f&>c [ i=: < ?&.> (>:?i$7)$&.>i{.$d [ i=: 3
] b=: f&>c [ i=: < ?&.> (>:?i$7)$&.>i{.$d [ i=: 4
] b=: f&>c [ i=: < ?&.> (>:?i$7)$&.>i{.$d [ i=: 5

] b=: f&>c [ i=: < ?&.> (>:?i$25 4)$&.>i{.$d [ i=: 1
] b=: f&>c [ i=: < ?&.> (>:?i$25 4)$&.>i{.$d [ i=: 2
] b=: f&>c [ i=: < ?&.> (>:?i$25 4)$&.>i{.$d [ i=: 3
] b=: f&>c [ i=: < ?&.> (>:?i$25 4)$&.>i{.$d [ i=: 4
] b=: f&>c [ i=: < ?&.> (>:?i$25 4)$&.>i{.$d [ i=: 5

s=: 1$.5 6;'';123
d=: 5 6$123
i=: <(?2$5);?3 2$6
x=: ?($i{d)$1000
s -: d
(x i}d) -: x i}s

'domain error' -: (3 4$'x') (<2 0;i.3   )} etx $.i.2 3 4
'domain error' -: (3 4$<4 ) (<2 0;i.3   )} etx $.i.2 3 4

'index error'  -: (i.2 3)   (< 4 0;0;i.3)} etx $.i.4 2 3
'index error'  -: (i.2 3)   (<_5 0;0;i.3)} etx $.i.4 2 3

'length error' -: (i.2 3)   (<2 0;2 1 0 )} etx $.i.4 3 2


NB. empty u
1 2 3 -: 27 ''} 1 2 3
1 2 3 -: 27 (0#a:)}1 2 3





epilog''

